// components/auth/auth.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    isLogin: '',
  },

  /**
   * 组件的方法列表
   */
  methods: {},
  // 生命周期
  lifetimes: {
    created() {},
    attached() {
      const token = getApp().token
      this.setData({
        isLogin: Boolean(token),
      })
      if (!token) {
        const pages = getCurrentPages()
        const page = pages[pages.length - 1]
        page.onLoad = () => {}
        page.onShow = () => {}
        page.onReady = () => {}
        wx.redirectTo({
          url: '/pages/login/index?redirectUrl=/' + page.route,
        })
      }
    },
  },
})
